#include <stdio.h>
int main()
{
    int num=0, date=0, sum, temp = 0;
    int a, b;
    int T = 1;
    for (; T <8 ; T++)
    {
        // today is T-th day
        scanf("%d%d", &a, &b);
        sum = a + b;


        if (sum <= 8) // happy
            continue;
        else // no happy
        {
            temp++;
            if (num < sum - 8) // find the biggest unhappy number
            {
                num = sum - 8;
                date = T; // record the date
            }
        }
    }
    if (temp == 0)
        printf("0\n");
    else
    {
        printf("%d\n", date);
    }
    return 0;
}